#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main() {
	int a = 0, b = 0;
	int num = 0;
	scanf("%d %d", &a, &b);
	while (b != 0) {
		num = b;
		b = a % b;
		a = num;
	}
	printf("%d\n", num);
	return 0;
}